package cn.wzby;

import java.nio.charset.StandardCharsets;
import java.util.Calendar;
import java.util.Locale;

public class Str5 {
    public static void main(String[] args) {

        String s = "hello字符串常用方法";
        //求多个字符
        System.out.println(s.length());
        // 求字符串有多少个字节
        System.out.println(s.getBytes().length);
        //转换大小写
        String a = "hello";
        String b = "HELLO";
        //转换大写
        System.out.println(a.toUpperCase());
        //转换小写
        System.out.println(b.toLowerCase());
        // 判断结尾
        System.out.println("Hello,java".endsWith("java"));
        System.out.println("Hello,java".endsWith("Hello"));
        //判断开头
        System.out.println("Hello,java".startsWith("H"));
        System.out.println("Hello,java".startsWith("h"));
        //判断是不是包括某字符串
        System.out.println("Hello".contains("Hello"));
        System.out.println("Hello".contains("H"));
        //  连接字符串
        System.out.println("hello" + "张北，年龄：" + 21 + " 岁 ");
        System.out.println("love".concat("wzby"));
        //判断字符串内容是否一样
        String s1 = "ok";
        String s2 = "Ok";
        System.out.println(s1 == s2);
        System.out.println(s1.equals(s2));
        System.out.println(s1.equalsIgnoreCase(s2));
        //不看大小写，看内容是否一样


        //判断位置
        System.out.println("Hello16java".indexOf("16"));
        System.out.println("Hello16java".indexOf("a"));
        System.out.println("H16ello16ja16va".indexOf("16", 8));
        //charAt()
        Calendar d = Calendar.getInstance();
        int k = d.get(Calendar.DAY_OF_WEEK) - 1;
        System.out.println("星期" + "日一二三四五六".charAt(k));
        //截取字符串
        System.out.println("hellojava".substring(5));
        System.out.println("hellojava".substring(5, 8));
        //替换字符串
        System.out.println("java,wzby-wzby-wzby".replace("wzby", "ybzw").replace("ybzw", ""));


    }
}
